package com.hns.can.upgrade.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.Query;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hns.can.upgrade.entity.UpgPhoneParam;
import com.hns.can.upgrade.entity.UpgPhoneVrsn;
import com.hns.frame.mybatis.Pagination;
import com.hns.frame.service.CommonService;
import com.hns.tool.pub.PubUtil;

/**
 * 
* @ClassName: UpgPhoneVrsnService 
* @Description: 手机升级版本
* @author zhangl
* @email victor_007@126.com
* @date 2016年11月15日 上午11:22:22
 */
@Service
public class UpgPhoneVrsnService extends CommonService{

    /**
     * 
     * @Title:  getUpgPhoneVrsn
     * @Description: 版本分页
     * @return
     * Pagination
     */
    public Pagination getUpgPhoneVrsnPage(Map<String, Object> params) {
        Pagination page = this.myBatisPage("upgPhone.getUpgPhoneVrsnCount", "upgPhone.getUpgPhoneVrsnPage", params,UpgPhoneVrsn.class);
        return page;
    }
    
    /**
     * 
     * @Title:  getUpgPhoneParamList
     * @Description: 参数分页
     * @param params
     * @return
     * List<UpgPhoneParam>
     */
    public Pagination getUpgPhoneParamPage(Map<String, Object> params){
        Pagination page =  this.myBatisPage("upgPhone.getUpgPhoneParamCount","upgPhone.getUpgPhoneParamList",params,UpgPhoneParam.class);
        return page;
    }
    
    /**
     * 
     * @Title:  getUpgPhoneParamList
     * @Description: 参数列表
     * @param params
     * @return
     * List<UpgPhoneParam>
     */
    public List<UpgPhoneParam> getUpgPhoneParamList(Map<String, Object> params){
        List<UpgPhoneParam> list =  PubUtil.convertListMapToObject(this.sqlMapDao.selectList("upgPhone.getUpgPhoneParamList",params),UpgPhoneParam.class);
        return list;
    }
    
    
    /**
     * 
     * @Title:  getUpgPhoneVrsn
     * @Description: 获取版本
     * @param vrsnId
     * @return
     * UpgPhoneVrsn
     */
    public UpgPhoneVrsn getUpgPhoneVrsn(String vrsnId) {
        UpgPhoneVrsn upgPhoneVrsn = this.commonEntityDao.find(vrsnId, UpgPhoneVrsn.class);
        return upgPhoneVrsn;
    }

    /**
     * 
     * @Title:  addUpgPhoneVrsn
     * @Description: 添加版本
     * @param entity
     * void
     */
    @Transactional
    public void addUpgPhoneVrsn(UpgPhoneVrsn entity) {
        this.commonEntityDao.save(entity);
    }
    
    /**
     * 
     * @Title:  updUpgPhoneVrsn
     * @Description: 修改版本
     * @param entity
     * void
     */
    @Transactional
    public void updUpgPhoneVrsn(UpgPhoneVrsn entity) {
        this.commonEntityDao.update(entity);
    }

    /**
     * 
     * @Title:  deleteUpgPhoneVrsn
     * @Description: 删除版本
     * @param vrsnIds
     * void
     */
    @Transactional
    public void deleteUpgPhoneVrsn(String[] vrsnIds) {
        commonEntityDao.delete(UpgPhoneVrsn.class, vrsnIds);
    }
    
    /**
     * 
     * @Title:  getUpgPhoneParam
     * @Description: 获取参数 by ID
     * @param paramId
     * @return
     * UpgPhoneVrsn
     */
    public UpgPhoneParam getUpgPhoneParam(String paramId) {
        UpgPhoneParam upgPhoneParam = this.commonEntityDao.find(paramId, UpgPhoneParam.class);
        return upgPhoneParam;
    }
    
    public UpgPhoneParam getUpgPhoneParam(Map<String,Object> params) {
        String jpql = "SELECT T FROM UpgPhoneParam T WHERE T.type =:type";
        UpgPhoneParam upgPhoneParam = this.commonEntityDao.findOneByJpql(jpql, params);
        return upgPhoneParam;
    } 
    
    /**
     * 
     * @Title:  updUpgPhoneParam
     * @Description: 参数修改
     * @param entity
     * void
     */
    @Transactional
    public void updUpgPhoneParam(UpgPhoneParam entity) {
        this.commonEntityDao.update(entity);
    }

}
